import { defineConfig } from 'vite'
import path from 'path'
import vue from '@vitejs/plugin-vue'
import react from '@vitejs/plugin-react'

export default defineConfig({
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src'),
      'react': path.resolve('./node_modules/react'),
      'react-dom': path.resolve('./node_modules/react-dom')
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        // additionalData: `@use "@/styles/element/index.scss" as *;`,
        api: "modern-compiler",
        //去掉提示 Deprecation Warning: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0
        silenceDeprecations: ['legacy-js-api'],
      },
    },
    modules: {
      localsConvention: 'camelCaseOnly'
    }
  },
  optimizeDeps: {
    include: ['@antv/x6']
  },
  plugins: [
    vue({
      template: {
        compilerOptions: {
          // 允许使用自定义元素
          isCustomElement: tag => tag.includes('lite-flow-editor')
        }
      }
    }),
    react()
  ],
  server: {
    proxy: {
      '/tansci': {
        target: 'http://localhost:7000',
        //target: 'http://rgblive.cn',
        changeOrigin: true
      },
      '/xxl-job-admin': {
        target: 'http://rgblive.cn',
        changeOrigin: true
      }
    } as any
  }
})
